<?php
/**
 * Created by PhpStorm.
 * User: CuYen
 * Date: 5/20/14
 * Time: 12:16 AM
 */
if(! defined('BASEPATH')) exit(" You forget include base path!");
// class Name for model
class Fetchdata extends CI_Model
{
    public function __construct()
    {
        parent::__construct();
        $this->load->database(); // load database you use method ->db->method(param);
    }
    // function get all users from table users
    public function get_list_users()
    {
        // in the case 1:
        $query = $this->db->query("select * from users ORDER BY username ASC");
        // you can write as

        // in the case 2: you can write like thís
        $this->db->select("*");
        $this->db->order_by("username ASC");
        $query = $this->db->get("users"); // when you get data from table with method ->db->get("table_name") $query <=> $this->db
        var_dump($query);
        return $query->result_array(); // because $query is object $this->db so you can active method result_array()
    }
}